<?php
namespace app\admin\controller;

use app\common\controller\AdminBase;
use think\Db;
use think\Request;
use think\Loader;
use think\Url;

class Resumelibrary extends AdminBase
{
    public function index()
    {
        
        return $this->fetch();

    }
    public function latest()
    {
        $userData=Db::table('link_man')->where('user_status',1)->select();
        //$userData = Loader::model('Resumelibrary')->getLatest();

        //var_dump($userData);exit;
        
        foreach($userData as $key=>$value){
            $userData[$key]['age']=date('Y',time())-substr($value['id_number'],6,-8);
            $userData[$key]['applyForJob']=$this->applyForJob($value['apply_for_job'])['job_name'];
            $userData[$key]['applyForJobDep']=$this->applyForJob($value['apply_for_job'])['dep_name'];      
        }
             
		//print_r($userData);exit;
        $this->assign('userData',$userData);
        
        return $this->fetch();
    }
    
    public function applyForJob($jobId)
    {
        
            $userJobData=Db::table('recruitment_jobs')->where('job_id',$jobId)->find();
            $data['job_name']=$userJobData['job_name'];
            $userDepartmentData=Db::table('department')->where('department_id',$userJobData['department_id'])->find();

        $data['dep_name']=$userDepartmentData['department_name'];
        
        return $data;
//        var_dump($data);
           
    } 
    
    public function talk(){
    	
    	
    }
}


